<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:thSys="">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" th:href="${#maps.containsKey(options,'ico_logo') == false ? '/static/img/favicon.ico' : options['ico_logo'] }"/>
    <link rel="stylesheet" type="text/css" href="/plugins/vali/css/main.css">
    <link rel="stylesheet" type="text/css" href="/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/plugins/toast/jquery.toast.css">
  	<title thSys:text="'后台登录'"></title>
  </head>
  <body>
    <section class="material-half-bg">
      <div class="cover"></div>
    </section>
    <section class="login-content">
      <div class="logo">
        <h1>MayDay</h1>
      </div>
      <div class="login-box">
        <form class="login-form">
         <h3 class="login-head"><i class="fa fa-lg fa-fw fa-user"></i>登录</h3>
          <div class="form-group">
            <input class="form-control" id="userName" type="text" name="userName" placeholder="用户名" autofocus>
          </div>
          <div class="form-group">
            <input class="form-control" id="userPwd" type="password" name="userPwd" placeholder="密码">
          </div>
          <div class="form-group btn-container">
            <button class="btn btn-outline-primary btn-block" id="btn_login"  type="button" onclick="getLogin()">登录</button>
          </div>
        </form>
      </div>
    </section>
  <div th:replace="admin/module/macros :: comm" ></div>
  <script type="text/javascript">
  //回车登录事件
  $("#userPwd").keyup(function(event){
	  if(event.keyCode ==13){
		  getLogin();
	  }
	});
    function getLogin() {
        var userName=$("#userName").val();
        var userPwd=$("#userPwd").val();
        loadingText("btn_login","登录中...");
        $.ajax({
            type: "post",
            url: "/admin/getLogin",
            dataType :"json",
            async: false,
            data: {userName:userName,userPwd: userPwd},
            success:function (data) {
            	if(data.flag==true){
            		 $.toast({
                         text: data.msg,
                         heading: '提示',
                         icon: 'success',
                         showHideTransition: 'fade',
                         allowToastClose: true,
                         hideAfter: 1000,
                         stack: 1,
                         position: 'top-center',
                         textAlign: 'left',
                         loader: true,
                         loaderBg: '#ffffff',
                         afterHidden: function () {
                        	 window.location.href = "/admin/login"; 
                         }
                     });
            	}else{
            		loadingBack("btn_login","登录");
            		showMsg(data.msg,"error",3000);
            	}
            },error:function (data) {
            	loadingBack("btn_login","登录");
            	showMsg("登录失败","error",3000);
            }
        });
    }
  </script>
  </body>
</html>